  <table>
    <% $view %>
  </table>
<%args>
  $kind
  $dir
</%args>
<%init>
  my $view;
  my @view;
  push @view, "<table>";
  if ( $kind eq 'raw' ) {
    foreach my $file ( `ls $TRFLP::data_path/$dir/*.sample` ) {
      chomp $file;
      $file =~ s/.sample$//;
      my $name = (split "/", $file)[-1];
      push @view, qq(<tr><td><img src="plot.html?stage=raw_data;key=$name;file=$file"></td></tr>);
    }
  }
  elsif ( $kind eq 'clipped' ) {
    foreach my $file ( `ls $TRFLP::data_path/$dir/*.standard` ) {
      chomp $file;
      $file =~ s/.clipped$//;
      my $name = (split "/", $file)[-1];
      push @view, qq(<tr><td><img src="plot.html?stage=clipped_ladder;key=$name;file=$file"></td></tr>);
    }
  }
  elsif ( $kind eq 'target' ) {
    foreach my $file ( `ls $TRFLP::data_path/$dir/*.target` ) {
      chomp $file;
      $file =~ s/.target$//;
      my $name = (split "/", $file)[-1];
      push @view, qq(<tr><td><img src="plot.html?stage=target;key=$name;file=$file"></td></tr>);
    }
  }
  elsif ( $kind eq 'warped' ) {
    foreach my $file ( `ls $TRFLP::data_path/$dir/*.warped` ) {
      chomp $file;
      $file =~ s/.warped$//;
      my $name = (split "/", $file)[-1];
      push @view, qq(<tr><td><img src="plot.html?stage=warped;key=$name;file=$file"></td></tr>);
    }
  }
  elsif ( $kind eq 'peaks' ) {
    foreach my $file ( sort { substr((split "/", $a)[-1], 4) cmp substr((split "/", $b)[-1], 4) } `ls $TRFLP::data_path/$dir/*.peak` ) {
      chomp $file;
      $file =~ s/.peak$//;
      my $name = (split "/", $file)[-1];
      push @view, qq(<tr><td><a href="$file.peak">$name peak data</a></td></tr>\n);
      push @view, qq(<tr><td><img border="0" src="plot.html?stage=peaks;key=$name;file=$file"></td></tr>);
    }
  }
  else {
    push @view, "<tr><td>Don't know how to display '$kind'</td></tr>";
  }
  push @view, "</table>";
  $view = join("\n", @view);
</%init>
<%method title>
<%args>
  $kind
  $dir
</%args> \
Signal Viewer (<% $kind %>): <% $dir %> \
</%method>
